<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 存复杂类型
        obj={
            name:'hhb'
            ,age:17,
            sex:'男'
        }
        // 看不了所以要转换成字符串
        // localStorage.setItem('键名',键值) 
        localStorage.setItem('obj',JSON.stringify(obj))
    //  console.log( localStorage.getItem('obj'));  
        // 获取的时候因为转换成字符串了所以只能看所以转换成对象类型
       let str= localStorage.getItem('obj')
      console.log(JSON.parse(str)); 
    </script>
</body>
</html>